package com.zf.admin.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zf.admin.pojo.Checkout;
import com.zf.admin.service.CheckoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/checkout")
public class CheckoutController {
    @Autowired
    private CheckoutService checkoutService;

    @RequestMapping("/getallcheckout")
    public String getallcheckout(Model model, @RequestParam(required = false, defaultValue = "1") Integer page,
                                 @RequestParam(required = false, defaultValue = "2") Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        List<Checkout> checkout = checkoutService.getallcheckout();
        PageInfo<Checkout> p = new PageInfo<Checkout>(checkout);
        model.addAttribute("p", p);
        model.addAttribute("checkout", checkout);
        model.addAttribute("mainPage", "checkout.jsp");
        return "admin/main1";
    }


}
